import { createSlice } from '@reduxjs/toolkit'

export const personListSlice=createSlice({
    name:"person",
    initialState:{
        personList:[
            {
                id:'1',
                name:"张三",
                code:"123346547658694653",
            },
            {
                id:'2',
                name:"李四",
                code:"132465476988609567",
            },
        ]
    },
    reducers:{
        delPersonList(state, action){
            state.personList=state.personList.filter((v)=>v.id!==action.payload.id)
        },
        addPersonList(state, action){
            state.personList.push({
                ...action.payload,
                id:new Date().getTime()
            })
        }
    }
})
export const {delPersonList,addPersonList}=personListSlice.actions